Skip to content

Conversation

duzda
Copy link
Contributor

@duzda duzda commented Aug 31, 2025

Does not fully implement RequestInit, only what seemed useful.

Closes: #4
Deprecates: #5

Does not fully implement RequestInit, only what seemed useful.

Closes: gleam-lang#4
@duzda
Copy link
Contributor Author

duzda commented Sep 4, 2025

Hi @lpil, just to let you know, I will open the PR for the second part of #19 once this one gets merged, as it depends directly on this one

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Thank you for this. I'm sure people will find it very useful.

We never use _with suffixes in Gleam core, so we'll need to adjust this design slightly. Could you adopt the same pattern that the gleam_httpc library uses please: https://hexdocs.pm/gleam_httpc/gleam/httpc.html

I've left some notes inline with more details.

|> fetch_options.set_credentials(fetch_options.CredentialsOmit)
|> fetch_options.set_keepalive(True)
|> fetch_options.set_priority(fetch_options.High)
|> fetch_options.set_redirect(fetch_options.Follow)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this test verify? Doesn't seem like there's assertions for any of these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've expanded on this one and tried to write all of the tests, sadly node-fetch polyfill doesn't implement most of this stuff, so it's not testable. Since node is running V8, it does however error out on wrong values, therefore simply assigning values and checking whether requests succeed is imo good enough.

@@ -0,0 +1,184 @@
import gleam/dynamic.{type Dynamic}

/// Gleam equivalent of JavaScript [`RequestInit`](https://developer.mozilla.org/docs/Web/API/RequestInit).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap doc comments at 80 lines like regular Gleam code, and included documentation for each option rather solely linking to an external resource 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to include "something" it's still mostly Mozilla docs shortened.

@lpil lpil marked this pull request as draft September 7, 2025 12:45
@duzda
Copy link
Contributor Author

duzda commented Sep 14, 2025

Hi @lpil! I've tried to implement most of your comments. Moved some stuff around, expanded more on the tests and docs. Regarding docs, I'm kinda lost what more to include. Definitely expecting few more changes regarding naming.

Also will squash once ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing options when sending fetch requests
2 participants